package com.orphan.util.mqConfig;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SettlementMq {
    @Autowired
    CachingConnectionFactory cachingConnectionFactory;

    //创建队列
    @Bean
    public Queue settlementQueue1(){
        return new Queue("settlementQueue1");
    }
    //创建默认交换机
    @Bean
    public DirectExchange settlementDirectExchange1(){
        return new DirectExchange("SettlementDirectExchange1" );
    }
    //把队列绑定到交换机
    @Bean
    public Binding settlementOrderToDirectExchange(Queue settlementQueue1,DirectExchange settlementDirectExchange1){
        return BindingBuilder.bind(settlementQueue1).to(settlementDirectExchange1).with("settlementMessage");
    }


    //创建队列
    @Bean
    public Queue settlementBackQueue(){
        return new Queue("settlementBackQueue");
    }
    //创建默认交换机
    @Bean
    public DirectExchange SettlementBackDirectExchange(){
        return new DirectExchange("SettlementBackDirectExchange" );
    }
    //把队列绑定到交换机
    @Bean
    public Binding settlementBackToDirectExchange(){
        return BindingBuilder.bind(settlementBackQueue()).to(SettlementBackDirectExchange()).with("settlementBackMessage");}

}
